package com.ruoyi.project.system.domain;


import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.aspectj.lang.annotation.Excels;
import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type;
import com.ruoyi.framework.web.domain.MbEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;

/**
 * 用户信息对象 sys_user
 *
 * @author ruoyi
 * @date 2020-05-28
 */
@Data
@TableName("sys_user")
@ApiModel(value="sys_user对象", description="用户信息")
public class SysUser extends MbEntity {

    @TableId(value = "user_id", type = IdType.AUTO)
    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @Excel(name = "律所ID")
    @TableField("dept_id")
    @ApiModelProperty(value = "律所ID")
    private Long deptId;

    @Excel(name = "律所ID", readConverterExp = "冒=号分隔")
    @TableField("Lawfirm")
    @ApiModelProperty(value = "律所ID（冒号分隔）")
    private String lawfirm;

    @Excel(name = "团队ID", readConverterExp = "冒=号分隔")
    @TableField("team_id")
    @ApiModelProperty(value = "团队ID（冒号分隔）")
    private String teamId;

    @Excel(name = "用户账号")
    @TableField("user_name")
    @ApiModelProperty(value = "用户账号")
    private String userName;

    @Excel(name = "用户昵称")
    @TableField("nick_name")
    @ApiModelProperty(value = "用户昵称")
    private String nickName;

    @Excel(name = "用户类型", readConverterExp = "0=0系统用户")
    @TableField("user_type")
    @ApiModelProperty(value = "用户类型（00系统用户）")
    private String userType;

    @Excel(name = "用户邮箱")
    @TableField("email")
    @ApiModelProperty(value = "用户邮箱")
    private String email;

    @Excel(name = "手机号码")
    @TableField("phonenumber")
    @ApiModelProperty(value = "手机号码")
    private String phonenumber;

    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    @TableField("sex")
    @ApiModelProperty(value = "用户性别（0男 1女 2未知）")
    private String sex;

    @Excel(name = "头像地址")
    @TableField("avatar")
    @ApiModelProperty(value = "头像地址")
    private String avatar;

    @Excel(name = "密码")
    @TableField("password")
    @ApiModelProperty(value = "密码")
    private String password;

    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    @TableField("status")
    @ApiModelProperty(value = "帐号状态（0正常 1停用）")
    private String status;

    @TableField("del_flag")
    @ApiModelProperty(value = "删除标志（0代表存在 2代表删除）")
    private String delFlag;

    @Excel(name = "最后登陆IP")
    @TableField("login_ip")
    @ApiModelProperty(value = "最后登陆IP")
    private String loginIp;

    @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") //格式化前台日期入参注解
    @TableField("login_date")
    @ApiModelProperty(value = "最后登陆时间")
    private Date loginDate;

    @TableField("create_by")
    @ApiModelProperty(value = "创建者")
    private String createBy;

    @TableField("create_time")
    @ApiModelProperty(value = "创建时间（提交认证时间）")
    private Date createTime;

    @TableField("update_by")
    @ApiModelProperty(value = "更新者")
    private String updateBy;

    @TableField("update_time")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @Excel(name = "备注")
    @TableField("remark")
    @ApiModelProperty(value = "备注")
    private String remark;

    @Excel(name = "身份类型")
    @TableField("identity_type")
    @ApiModelProperty(value = "身份类型")
    private String identityType;

    @Excel(name = "身份证")
    @TableField("id_card")
    @ApiModelProperty(value = "身份证")
    private String idCard;

    @Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") //格式化前台日期入参注解
    @TableField("birthday")
    @ApiModelProperty(value = "生日")
    private Date birthday;

    @Excel(name = "从业时间", width = 30, dateFormat = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") //格式化前台日期入参注解
    @TableField("working_time")
    @ApiModelProperty(value = "从业时间")
    private Date workingTime;

    @Excel(name = "所在地区")
    @TableField("region")
    @ApiModelProperty(value = "所在地区")
    private String region;

    @Excel(name = "业务专长")
    @TableField("expertise")
    @ApiModelProperty(value = "业务专长")
    private String expertise;

    @Excel(name = "个人简介")
    @TableField("introduce")
    @ApiModelProperty(value = "个人简介")
    private String introduce;

    @Excel(name = "资质文件路径", readConverterExp = "冒=号分隔")
    @TableField("file_urls")
    @ApiModelProperty(value = "资质文件路径（冒号分隔）")
    private String fileUrls;

    @Excel(name = "审核状态")
    @TableField("audit_status")
    @ApiModelProperty(value = "审核状态")
    private Integer auditStatus;

    @Excel(name = "审核律所ID")
    @TableField("audit_law_id")
    @ApiModelProperty(value = "审核律所ID")
    private Integer auditLawId;

    @Excel(name = "审核律所名称")
    @TableField("audit_law")
    @ApiModelProperty(value = "审核律所名称")
    private Integer auditLaw;

    /** 部门对象 */
    @Excels({
            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
            @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
    })
    @TableField(exist = false)
    private SysDept dept;

    /** 角色对象 */
    @TableField(exist = false)
    private List<SysRole> roles;

    /** 角色组 */
    @TableField(exist = false)
    private Long[] roleIds;

    /** 岗位组 */
    @TableField(exist = false)
    private Long[] postIds;

    public SysUser()
    {

    }

    public SysUser(Long userId)
    {
        this.userId = userId;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

}
